<template>
	<view>
		<u-navbar title="编辑" :border-bottom='false'>
			<view slot='right' style='padding-right: 32rpx;font-size: 30rpx;color: #3587F7;' @click="comfirm">
				完成
			</view>
		</u-navbar>
		<view class="container">
			<view class="tips">
				<text style="color: #E5793B;">小贴士：</text><text style="color: #666666;">姓名需与乘机证件一致，否则会影响登机</text>
			</view>
			<view class="infoBox">
					<u-form :model="form" ref="uForm">
						<u-form-item label="姓名"><u-input v-model="form.name" placeholder="请输入姓名" /></u-form-item>
						<u-form-item label="证件类型"><u-input type="select" v-model="form.type" /></u-form-item>
						<u-form-item label="证件号码"><u-input v-model="form.number" placeholder="请输入证件号" /></u-form-item>
						<u-form-item label="手机号码"><u-input type="number" v-model="form.mobile" placeholder="请输入手机号" /></u-form-item>
					</u-form>
			</view>
		</view>
	</view>
</template>

<script>
	import myRequest from '@/api/index.js'
	export default {
		data(){
			return {
				form:{
					name:'',
					number:'',
					type:'身份证',
					mobile:''
				},
				id:''
			}
		},
		onLoad(option) {
			this.form.name = option.name
			this.form.number = option.num
			this.id = option.id
		},
		methods:{
			async comfirm(){
				let { form ,id} = this
				if(!form.name){
					uni.showToast({
						title:'请输入姓名',
						icon:'none'
					})
					return
				}
				if(!form.number){
					uni.showToast({
						title:'请输入证件号',
						icon:'none'
					})
					return
				}
				if(!form.mobile) {
					uni.showToast({
						title:'请输入手机',
						icon:'none'
					})
					return
				}
				let res =await myRequest.addTripman({
					id_name:form.name,
					id_number:form.number,
					id_type:'1',
					id:id,
					mobile:form.mobile
				})
				if(res.status) {
					uni.showToast({
						title:'新增成功',
						success() {
							uni.navigateBack({
								delta:1
							})
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		
		.tips {
			padding: 0 28rpx;
			width: 100%;
			height: 80rpx;
			background: #FEF7EF;
			font-size: 24rpx;
			font-family: Segoe UI;
			font-weight: 400;
			line-height: 80rpx;
		}
		.infoBox {
			width: 100%;
			height: auto;
			padding: 0 28rpx;
			background-color: #FFFFFF;
		}
	}
	
	/deep/ .u-form-item--left {
		flex:0 0 160rpx !important;
	}
</style>
